package com.blacktea.behavioralpatterns.interpreterpattern;

/**
 * @description: and 表达式
 *  非终结符表达式类，它表示与运算。它需要一个左表达式和右表达式作为参数。
 * @author: black tea
 * @date: 2023/3/25 15:23
 */
public class AndExpression implements Expression {
    private final Expression left;
    private final Expression right;

    public AndExpression(Expression left, Expression right) {
        this.left = left;
        this.right = right;
    }

    @Override
    public boolean interpret(Context context) {
        return left.interpret(context) && right.interpret(context);
    }
}
